/********************************************************************
	created:	2010/10/01
	created:	1:10:2010   22:30
	filename: 	f:\CONG DUNG\ExtremeProgramingChallenge\Pathman\Pathman\CSounds.h
	file path:	f:\CONG DUNG\ExtremeProgramingChallenge\Pathman\Pathman
	file base:	CSounds
	file ext:	h
	author:		WaZoombie
	
	purpose:	Class to manage sounds.
*********************************************************************/

#ifndef _CSOUNDS_H_
#define _CSOUNDS_H_

/// Include files
#include "bass.h"
#include <map>
#include <iterator>
#include <stdio.h>
#include <string>
#include <stdlib.h>

using namespace std;

#pragma comment (lib, "Bass.lib")

typedef enum {
	STR_MP123_OGG_WAV_AIFF,
	STR_MOD
} STREAM_TYPE;

typedef struct {
	DWORD			hStream;
	STREAM_TYPE		type;
} STREAM_NODE;

//  CSounds class
class CSounds {
public:
	/// Constructor
	CSounds(HWND		hwnd);

	/// Destructor
	~CSounds();

	/// Initialize sound system
	bool		init(int	device,	DWORD freqs, DWORD flags);


	/// Add a file to list
	/// \param	filename	: Filename
	/// \param	name		: The name we specify to use in list
	/// \param	flags		: BASS system flag
	bool			addFile(STREAM_TYPE type, string name, string filename, DWORD flag);

	/// Remove a sound.
	bool		remove(string name);

	/// Play a sound
	bool		play(string name, bool restart);

	/// Check if a sound is playing
	DWORD		getState(string name);

	/// Pause a sound
	bool		pause(string name);

	/// Stop sound
	bool		stop(string name);

	/// Pause all
	void		pauseAll();

	/// Stop all
	void		stopAll();

	/// Resume all
	void		resumeAll();

	/// Set volume value for an item
	void		setItemVolume(string name, int val);

	/// Set global volume
	void		setGlobalVolume(int val);

private:
	/// Store all sounds
	map<string, STREAM_NODE>	m_sounds;

	HWND						m_hwnd;			// Window handle
	int							m_device;		// Device
	DWORD						m_freq;
	DWORD						m_flags;
};

#endif